import React from 'react'
import HoLogin from '../../Utils/HoLogin';
import { Cell, Image ,Toast, NavBar,Button } from 'react-vant';
import { useNavigate } from 'react-router-dom';

function My() {
    // 11.进入到个人信息页，如果已登录展示用户名和头像，如果未登录展示去登录按钮
    const Navigate = useNavigate();
    const user = window.localStorage.getItem('user');
    const token = window.localStorage.getItem('token');
    // console.log(user);
    
    return (
        <div className='My'>
            <NavBar title="个人信息页"/>
            <Cell style={{display:token ? 'block' :'none'}}
                center
                title={<>用户名 : {user}</>}
                icon={
                    <Image
                    width={44}
                    height={44}
                    src='https://img.yzcdn.cn/vant/cat.jpeg'
                    round
                    />
                }
            />
            <p style={{display:token ? 'none' :'block'}}>
                您还未登录，请先登录 &emsp;
                {/* 12.点击去登录进入到登录页，正确进行登录 */}
                <Button type="warning" size="small"  onClick={()=>Navigate('/Login')}>去登录</Button>
            </p>
        </div>
    )
}

export default My